package com.huping.mapper;

import com.huping.pojo.Grade;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface ScoreRecordMapper {



 @Insert( "insert into  score_record (homework_id,giver_id,receiver_id,sequence)values (#{homeworkId},#{userid},#{receiver_id},#{sequence})")
  public int insertScoreRecord(Integer homeworkId,String userid,String receiver_id,Integer sequence);

    @Select("select count(*) from score_record where giver_id=#{userid} and homework_id = #{homeworkId} and receiver_id=#{receiver_id}")
    public long checkScoreRecordExist(String userid,Integer homeworkId,String receiver_id);

    Integer getSequence(String userid,Integer homeworkId);

    public Map<String,Object> getHomeworkBySequence(String userid,Integer sequence,Integer homeworkId);

    @Update("update score_record set score=#{score} ,grade_time=#{gradeTime} ,comment=#{comment} where giver_id=#{userid} and receiver_id=#{receiverId} and homework_id=#{homeworkId}")
    public int updateHupingScore(Integer score, Date gradeTime, String userid, String receiverId, Integer homeworkId,String comment);
    public List<Map<String ,Object>> selectHistricalReading(String userid, Integer homeworkId);


    @Select("select count(*) from score_record where score_record_id=#{ScoreRecordId} ")
    public  int checkSomeoneRecordExist(Integer ScoreRecordId);

    public  List<Map<String,Object>> getAllScoreRecord(String userid,Integer homeworkId);

}
